<script setup>
import { Plus } from "@element-plus/icons-vue";
import useTable from "@/utils/useTable";
import {http} from "@/api";
import { useStore } from "vuex";
const store = useStore()
/**
 * 表格
 * @type {Ref<UnwrapRef<*[]>>}
 */
const {
  searchParams,
  pageNo,
  pageSize,
  total,
  changePage,
  changeSize,
  dataSource,
  search,
  reset,
  openAdd,
  openEdit,
  openDelete
} = useTable({
  requestFn: http.answer,
  routerPre: 'answer',
  params: {
    user_id: store.getters.userInfo.type === 0 ? store.getters.userInfo.id : undefined
  }
})
</script>


<template>
  <PageMain title="答题结果">
    <el-form label-suffix="：" inline>
      <el-form-item>
        <el-button type="primary" @click="search">刷新</el-button>
      </el-form-item>
    </el-form>
    <div class="table-box">
      <el-table :data="dataSource">
        <el-table-column label="答题编号" prop="order_no">
        </el-table-column>
        <el-table-column label="答题人" prop="user.nickname">
        </el-table-column>
        <el-table-column label="答题时间" prop="create_time">
        </el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <el-button type="text" @click="openEdit(scope.row)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          v-model:current-page="pageNo"
          v-model:page-size="pageSize"
          :page-sizes="[10, 50, 100, 200]"
          background
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="changeSize"
          @current-change="changePage"
      />
    </div>
  </PageMain>
</template>

<style scoped lang="scss">

</style>
